      SUBROUTINE BOUNDS
C
C        'BOUNDS',THROUGHT INPUT OR PRESET VALUES, CALCULATES UPPER
C        AND LOWER BOUNDS FOR THE DERIVATIVES WHICH ARE USED IN 'ADMIMP'
C
      IMPLICIT REAL*8 (A-H,O-Z)
      REAL*8 NAME     ,NAME1(2),NAMD(10,3),NAMV(4)
      REAL*4 ACNTRL
C
      COMMON/ANTENA/ A(10,3),ADOT(10,3),B(10,3),BDOT(10,3),DIN(10,3),
     .               DINDOT(10,3),DOUT(10,3),DOUTDT(10,3),ZBZ(3,10),
     .               NELMTS,NDAMPR,MODES(10)
C
C
      COMMON/IMAIN1/ IDATE,LSAVE,INOPT,IPLOT,NUMEQS,IPLTPE,IORB,ITAPE
C
      COMMON/IPOOL1/ IGRAV,IDAMP,IK,K1,ITIM,IAB,IAPS,IBB,IBPS,NK(10),
     .               LK(10),LLK(10)
C
      COMMON/MOMENT/ ACNTRL,IVISCS,IATTDE,IMGMTS,IWHEEL,NPULSE
C
      COMMON/RMAIN1/ DELTAT,FACTOR,FREQ,TSTOP,DELMIT,
     .               UPBND(150),DNBND(150)
C
      COMMON/ XIN4 / UP(150),DN(150),CONSA,COMEG,AOOP,AOOPV,AOOP1,AOOPV1
     .              ,AIP,AIPV,AIP1,AIPV1,DOOP,DOOPV,DOOP1,DOOPV1,DIP,
     .               DIPV,DIP1,DIPV1,DUC,DUC1,DUCD,DUCD1
C
      COMMON/IAFSD/DELMAX,DELMIN,KCUT(150),NCUT,NUP
C
      COMMON/IBFSD/HEAD(150,4),NAME(150)
C
C     DIMENSION HEAD(150,4),HED1(4),HED2(4),HED3(4),HED4(4),HED5(4),
      DIMENSION             HED1(4),HED2(4),HED3(4),HED4(4),HED5(4),
     .          HED6(4),HED7(4),HED8(4),HED9(4)
C
C
      DATA NAME1/'PHI     ','PHIDOT  '/
C
      DATA NAMD /'(1,1)   ','(2,1)   ','(3,1)   ','(4,1)   ','(5,1)   ',
     .           '(6,1)   ','(7,1)   ','(8,1)   ','(9,1)   ','(10,1)  ',
     .           '(1,2)   ','(2,2)   ','(3,2)   ','(4,2)   ','(5,2)   ',
     .           '(6,2)   ','(7,2)   ','(8,2)   ','(9,2)   ','(10,2)  ',
     .           '(1,3)   ','(2,3)   ','(3,3)   ','(4,3)   ','(5,3)   ',
     .           '(6,3)   ','(7,3)   ','(8,3)   ','(9,3)   ','(10,3)  '/
C
      DATA NAMV /'Y(1)    ','Y(2)    ','Y(3)    ','S SUB Y '/
C
      DATA BLANK/'        '/
C
      DATA HED1 /'DAMPER O','UT-OF-PL','ANE DEFL','ECTIONS '/
      DATA HED2 /'DAMPER O','UT-OF-PL','ANE VELO','CITIES  '/
      DATA HED3 /'DAMPER I','N-PLANE ','DEFLECTI','ONS     '/
      DATA HED4 /'DAMPER I','N-PLANE ','VELOCITI','ES      '/
      DATA HED5 /'ANTENNA ','OUT-OF-P','LANE DEF','LECTIONS'/
      DATA HED6 /'ANTENNA ','OUT-OF-P','LANE VEL','OCITIES '/
      DATA HED7 /'ANTENNA ','IN-PLANE',' DEFLECT','IONS    '/
      DATA HED8 /'ANTENNA ','IN-PLANE',' VELOCIT','IES     '/
      DATA HED9 /'VISCOUS ','NUTATION',' DAMPING','        '/
C
C     ZERO INTEGRATOR DIAGNOSTIC COUNTERS
      DELMAX=0.0D0
      DELMIN=1.0D9
      NCUT=0
      NUP=0
C     ESTABLISH DEFAULT BOUNDS
      DO 5 I=1,150
      UPBND(I)=1.D20
      DNBND(I)=1.D20
      KCUT(I)=0
      DO 5 J=1,4
    5 HEAD(I,J)=BLANK
C
      JDAMPR=0
      JELMNT=0
C
C BOUNDS FOR 'A' ARRAY(SA)
C
C
      DO 10 I=1,6
      UPBND(I)=CONSA
   10 DNBND(I)=CONSA/1.D2
C
C BOUNDS FOR OMEG BODY RATES
C
      DO 20 I=1,3
      L=I + 6
      UPBND(L)=COMEG
   20 DNBND(L)=COMEG/1.D2
C
C CHECK FOR DAMPER CAGED(UNCAGED)
C
      IKOUNT=9
      IF(IDAMP.EQ.0) GO TO 30
C
C DAMPER UNCAGED NEED BOUNDS FOR PHI,PHIDOT
C
      IKOUNT=11
      UPBND(10)=DUC
      UPBND(11)=DUCD
      DNBND(10)=DUC1
      DNBND(11)=DUCD1
      NAME(10)=NAME1(1)
      NAME(11)=NAME1(2)
C
C CHECK FOR ANTENNA AND DAMPER BOUNDS REQUIREMENTS
C
   30 DO 40 I=1,IK
      IF(NK(I).NE.0) GO TO 50
   40 CONTINUE
C
      GO TO 131
C
   50 DO 130 K=1,IK
      M=NK(K)
      IF(M.EQ.0) GO TO 130
      IF((K-K1).GT.0) GO TO 90
      IF(JDAMPR.EQ.1) GO TO 90
C
C DAMPER BOUNDS
C
      DO 80 J=1,NDAMPR
      M=NK(J)
C
C DAMPER OUT OF PLANE
C
      DO 60 I=1,M
      IKOUNT=IKOUNT + 1
C
      DO 55 N=1,4
   55 HEAD(IKOUNT,N)=HED1(N)
C
   56 NAME(IKOUNT)=NAMD(J,I)
      UPBND(IKOUNT)=DOOP
   60 DNBND(IKOUNT)=DOOP1
C
C DAMPER OUT OF PLANE VELOCITY
C
      DO 65 I=1,M
      IKOUNT=IKOUNT + 1
C
      DO 63 N=1,4
   63 HEAD(IKOUNT,N)=HED2(N)
C
   64 NAME(IKOUNT)=NAMD(J,I)
      UPBND(IKOUNT)=DOOPV
   65 DNBND(IKOUNT)=DOOPV1
C
C DAMPER IN PLANE
C
      DO 70 I=1,M
      IKOUNT=IKOUNT + 1
C
      DO 66 N=1,4
   66 HEAD(IKOUNT,N)=HED3(N)
C
   67 NAME(IKOUNT)=NAMD(J,I)
      UPBND(IKOUNT)=DIP
   70 DNBND(IKOUNT)=DIP1
C
C DAMPER IN PLANE VELOCITY
C
      DO 75 I=1,M
      IKOUNT=IKOUNT + 1
C
      DO 73 N=1,4
   73 HEAD(IKOUNT,N)=HED4(N)
C
   74 NAME(IKOUNT)=NAMD(J,I)
      UPBND(IKOUNT)=DIPV
   75 DNBND(IKOUNT)=DIPV1
C
   80 CONTINUE
      JDAMPR=1
C
      GO TO 130
C
C ANTENNA BOUNDS
C
   90 IF(JELMNT.EQ.1) GO TO 130
      DO 120 L=1,NELMTS
      KK=L + K1
      M=NK(KK)
      IF(M.EQ.0) GO TO 120
C
C ANTENNA OUT OF PLANE
C
      DO 100 I=1,M
      IKOUNT=IKOUNT + 1
C
      DO 97 N=1,4
   97 HEAD(IKOUNT,N)=HED5(N)
C
   98 NAME(IKOUNT)=NAMD(L,I)
      UPBND(IKOUNT)=AOOP
  100 DNBND(IKOUNT)=AOOP1
C
C ANTENNA OUT OF PLANE VELOCITY
C
      DO 105 I=1,M
      IKOUNT=IKOUNT + 1
C
      DO 103 N=1,4
  103 HEAD(IKOUNT,N)=HED6(N)
C
  104 NAME(IKOUNT)=NAMD(L,I)
      UPBND(IKOUNT)=AOOPV
  105 DNBND(IKOUNT)=AOOPV1
C
C ANTENNA IN PLANE
C
      DO 110 I=1,M
      IKOUNT=IKOUNT + 1
C
      DO 108 N=1,4
  108 HEAD(IKOUNT,N)=HED7(N)
C
  109 NAME(IKOUNT)=NAMD(L,I)
      UPBND(IKOUNT)=AIP
  110 DNBND(IKOUNT)=AIP1
C
C ANTENNA IN PLANE VELOCITY
C
      DO 115 I=1,M
      IKOUNT=IKOUNT + 1
C
      DO 113 N=1,4
  113 HEAD(IKOUNT,N)=HED8(N)
C
  114 NAME(IKOUNT)=NAMD(L,I)
      UPBND(IKOUNT)=AIPV
  115 DNBND(IKOUNT)=AIPV1
C
  120 CONTINUE
      JELMNT=1
C
  130 CONTINUE
C
C CHECK FOR VISCOUS DAMPING
C
  131 IF(IVISCS.EQ.0) GO TO 140
C
C SET BOUNDS FOR VISCOUS DAMPING
C
      IKOUNT=IKOUNT + 1
C
      DO 135 NL=1,4
  135 HEAD(IKOUNT,NL)=HED9(NL)
C
      N=NUMEQS-3
      NAME(N)   =NAMV(1)
      NAME(N+1) =NAMV(2)
      NAME(N+2) =NAMV(3)
      NAME(N+3) =NAMV(4)
      UPBND(N)=   DUC
      UPBND(N+1)= DUC
      UPBND(N+2)= DUC
      UPBND(N+3)= DUCD
      DNBND(N)=   DUC1
      DNBND(N+1)= DUC1
      DNBND(N+2)= DUC1
      DNBND(N+3)= DUCD1
C
C CHECK FOR INPUT VALUES OF BOUNDS
C
  140 DO 150 I=1,NUMEQS
      IF(UP(I).GT.0.D0) UPBND(I)=UP(I)
  150 IF(DN(I).GT.0.D0) DNBND(I)=DN(I)
      RETURN
      END
